#include <stdio.h>
#include <stdlib.h>

// 获取星期几
/* char *getWeekDay(int n) {
  switch (n) {
  case 1: {
    return "Monday";
  } break;
  case 2: {
    return "Tuesday";
  } break;
  case 3: {
    return "Wednesday";
  } break;
  case 4: {
    return "Thursday";
  } break;
  case 5: {
    return "Friday";
  } break;
  case 6: {
    return "Saturday";
  } break;
  case 7: {
    return "Sunday";
  } break;
  default:
    return "invalid";
    break;
  }
} */
char *getWeekDay(int n) {
  char *weekdays[] = {"Monday", "Tuesday",  "Wednesday", "Thursday",
                      "Friday", "Saturday", "Sunday"};
  if (n < 1 || n > 7) {
    return "invalid";
  }
  return weekdays[n - 1];
}
int isLeapYear(int y) {
  if (y <= 0) {
    return -1;
  }
  if (y % 400 == 0 || y % 4 == 0 && y % 100 != 0) {
    return 1;
  } else {
    return 0;
  }
}

int main(int argc, char *argv[]) {
  /* 函数练习
   */
  // 判断星期几
  /* printf("请输入星期几：");
  int input = 0;
  scanf("%d", &input);
  char *wd = getWeekDay(input);
  printf("%s\n", wd); */
  // 判断是否是闰年
  printf("请输入年份：");
  int input;
  scanf("%d", &input);

  int rlt = isLeapYear(input);
  switch (rlt) {
  case 1: {
    printf("%d年是闰年\n", input);
  } break;
  case 0: {
    printf("%d年是平年", input);
  } break;
  case -1: {
    printf("%d是无效的年份", input);
  } break;
  }
  return EXIT_SUCCESS;
}
